package middleware

import (
	"bytes"
	"fmt"
	"github.com/gin-gonic/gin"
	"io"
)

func ReplayableBody() gin.HandlerFunc {
	return func(c *gin.Context) {
		fmt.Printf("Request: %s %s\n", c.Request.Method, c.Request.URL.Path)
		fmt.Printf("Headers: %v\n", c.Request.Header)
		body, _ := io.ReadAll(c.Request.Body)
		fmt.Printf("Body: %s\n", string(body))
		c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
		c.Next()
	}
}
